﻿using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XYS.Service.Core.Util.Helper
{
    /// <summary>
    /// 日志工厂帮助类
    /// </summary>
    public static class LoggerFactoryHelper
    {
        /// <summary>
        /// 创建一个日志工厂
        /// </summary>
        /// <returns></returns>
        public static ILoggerFactory CreateLoggerFactory(Action<ILoggingBuilder> configure = null)
        {
            if (configure == null)
            {
                configure = l => l.AddSimpleConsole(o =>
                {
                    o.IncludeScopes = true;
                    o.UseUtcTimestamp = false;
                    o.TimestampFormat = "[yyyy-MM-dd HH:mm:ss.fff]";
                })
                ;
            }
            return LoggerFactory.Create(configure);
        }
    }
}
